knitr::opts_chunk$set(echo = TRUE)
library(rmarkdown)
library(haven)
library(rdrobust)
library(ggplot2)
data <- read_dta("/Users/pablobrugarolas/Documents/Cloud/2020-21/RA Luis Miller/data/PA submit/do-data-files/Data/BM_PA.dta")
## Figure 2: RD effect for the turnout intention (0.8 window)
p <- rdplot(data$ivotd, data$z, h=0.8, p=0, binselect = "qsmv", kernel = "uniform", x.lim = c( -2.6, 2.6), y.lim = c(0.5, 1.00), y.label= "Turnout intention", x.label= "Running variable: days to the publication of Poll 1", col.lines = "#6A1B2E",  col.dots="black")
plot <- p[["rdplot"]]
plot.formated <-plot +geom_vline(xintercept=c(-0.8,0.8), linetype="dotted") +
theme(text=element_text(size=12),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_rect(fill = "transparent",colour = NA),
plot.background = element_rect(fill = "transparent",colour = NA),
plot.title = element_blank(),
legend.title = element_text(family = "Verdana"),
legend.text = element_text(family = "Verdana"),
axis.title.x= element_text(family = "Verdana"),
axis.text.x = element_text(family = "Verdana"),
axis.text.y = element_text(family = "Verdana"),
legend.position = "bottom")
plot.formated
ggsave(filename="Figure2.png", plot=plot.formated, device="png",
height=5, width=5, units="in", dpi=250, bg = "transparent")
